#include "connection.hpp"

int main()
{
    AsyncWorker::Ptr asyncWorkerPtr = std::make_shared<AsyncWorker>();
    // DLOG("111");

    Connection::Ptr connectionPtr = std::make_shared<Connection>("127.0.0.1", 8888, asyncWorkerPtr);
    //  DLOG("----");

    Channel::Ptr channelPtr = connectionPtr->openChannel();
    // DLOG("????");

    google::protobuf::Map<std::string, std::string> empty_map;
    // DLOG("111");
    channelPtr->declareExchange("exchange1", ExchangeType::TOPIC, true, false, empty_map);
    channelPtr->declareMsgQueue("queue1", false, true, false, empty_map);
    channelPtr->declareMsgQueue("queue2", false, true, false, empty_map);
    channelPtr->bind("exchange1", "queue1", "news.sport");
    channelPtr->bind("exchange1", "queue2", "news.music.#");
    DLOG("publish准备工作完毕");
    for (int i = 1; i <= 5; i++)
    {
        BasicProperty bp;
        bp.set_id(UUIDHelper::uuid());
        bp.set_delivery_mode(DeliveryMode::DURABLE);
        bp.set_routing_key("news.music.dj");
        channelPtr->basicPublish("exchange1", &bp, "hello-" + std::to_string(i));
    }

    // sleep(3);
    connectionPtr->closeChannel(channelPtr);

    // DLOG("closeChannel");
    return 0;
}